package com.example.socketdemo;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.annotation.NonNull;

public class SZdialogadpter extends Dialog {

    Context context;
    ConnectLister connectLister;
    EditText IP, Post;

    public SZdialogadpter(@NonNull Context context) {
        super(context);
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        View view = View.inflate(context, R.layout.sz_diaog, null);
        Button button = view.findViewById(R.id.connent);
        IP = view.findViewById(R.id.IP);
        Post = view.findViewById(R.id.post);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String ip = IP.getText().toString().trim();
                int post = Integer.valueOf(Post.getText().toString().trim());
                connectLister.connect(ip,post);

            }
        });
        setContentView(view);
    }

    public interface ConnectLister {
        void connect(String IP, int Post);
    }

    public void setConnectLister(ConnectLister connectLister) {
        this.connectLister = connectLister;
    }
}
